library _;

import 'package:flutter/material.dart';
import 'package:flutter_app/Page/Main/Main/Home/Category/main.dart';
import 'package:flutter_app/Page/Main/Main/Home/Suggest/main.dart';
import 'package:flutter_yfree/YFree.dart';

part 'view.dart';

class MainPage_Home extends YKeepAlivePage with SingleTickerProviderStateMixin {
  var tabs = ["推荐", "分类"];
  TabController? tabController;
  PageController pageController = PageController();
  List<YStatefulWidget> pages = [];

  final mainPage_Home_Suggest = MainPage_Home_Suggest(), mainPage_Home_Category = MainPage_Home_Category();
  List<YPage> mainPage_Home_Pages = [];

  @override
  void yOnCreate() {
    setState(() {
      tabController = TabController(length: tabs.length, vsync: this);
      mainPage_Home_Pages = [
        mainPage_Home_Suggest,
        mainPage_Home_Category,
      ];
      pages = mainPage_Home_Pages.map((e) => YStatefulWidget(() => e)).toList();
    });
  }

  @override
  void yOnDestory() {
    tabController?.dispose();
    pageController.dispose();
  }

  @override
  bool ySafeAreaBottom() => false;

  @override
  Widget yBuild(BuildContext context) {
    return tabController == null
        ? YEmpty()
        : Column(
            children: [
              view_topBar(),
              view_main(),
            ],
          );
  }
}
